package indi.h.security.signature;

import java.security.InvalidAlgorithmParameterException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.ECGenParameterSpec;

public class ECGOST_SV extends SignatureVerification{
	private String epsName;
	
	protected ECGOST_SV(String epsName) {
		super();
		this.epsName = epsName;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		try {
			//ECGOST3410NamedCurves.getNames()获取支持的类型,现在只是取其中一种
			ECGenParameterSpec eps=new ECGenParameterSpec(epsName);
			KeyPairGenerator kpg = KeyPairGenerator.getInstance(svParameter.getAlgorithm());
			if (svParameter.getSecureRandom() != null) {
				kpg.initialize(eps,
						new SecureRandom(svParameter.getSecureRandom().getBytes(svParameter.getCode())));
			} else {
				kpg.initialize(eps);
			}
			KeyPair kp = kpg.generateKeyPair();
			publicKey = kp.getPublic();
			privateKey = kp.getPrivate();
			initSignature();
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvalidAlgorithmParameterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
